package com.bnz.manager.controller;

import java.util.Arrays;
import java.util.Map;

import com.bnz.utils.PageUtils;
import com.bnz.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.bnz.manager.entity.ContentCategoryEntity;
import com.bnz.manager.service.ContentCategoryService;




/**
 * 内容分类
 *
 * @author zsl
 * @email 1966628784@qq.com
 * @date 2022-09-19 12:45:05
 */
@RestController
@RequestMapping("contentcategory")
public class ContentCategoryController {
    @Autowired
    private ContentCategoryService contentCategoryService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = contentCategoryService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") String id){
		ContentCategoryEntity contentCategory = contentCategoryService.getById(id);

        return R.ok().put("contentCategory", contentCategory);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody ContentCategoryEntity contentCategory){
		contentCategoryService.save(contentCategory);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody ContentCategoryEntity contentCategory){
		contentCategoryService.updateById(contentCategory);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody String[] ids){
		contentCategoryService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
